﻿{% extends "gma/base.html" %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__hd">
    <h1 class="page__title">
        <i class="fa fa-user weui_grid_icon_fa" style="font-size: 32px"> </i> {{ user.nickname }}
    </h1>
    <p class="page__desc"> ID: {{ user.id }} </p>
</div>

<div class="page__bd">
    <div class="weui-cells__title">信息内容</div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <textarea class="weui-textarea" id="hx_message" placeholder="请输入要发送给用户的私信" rows="10"></textarea>
            </div>
        </div>
    </div>
</div>

<div class="weui-btn-area">
    <a class="weui-btn weui-btn_block weui-btn_primary" href="javascript:send_hx_message()"> <i class="fa fa-envelope"></i> 发送私信 </a>
</div>

<div class="page__ft">
    <a href="{% url 'gma:home' %}">
        <span class="bottom-logo">
           HiBao
       </span>
    </a>
</div>

{% endblock content %}

<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}
<script>

function send_hx_message() {
    const hx_message = $('#hx_message').val();
    if (!hx_message) {
        alert("发送的内容不可以为空！");
        return;
    }

    let url = '{% url 'gma:api_send_hx_message' %}';
    let data = {
        'uid': {{ user.id }},
        'message': hx_message,
    };
    new my_ajax(url, data, '', '', () => {
        show_toast('发送成功');
        $('#hx_message').val('');
    });
}

</script>
{% endblock extra_js %}